package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.domain.Menu_management;
import com.itheima.domain.User_management;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface User_managementDao {
    @Select("select * from t_user")
    List<User_management> findAll();
    @Select("select * from t_user where id = #{userId}")
    User_management findById(Integer userId);
    @Update({"update user set id=#{id},birthday=#{birthday},gender=#{gender},username=#{username},name=#{name},roleId=#{roleid},loginTimes=#{logintimes},isEnable=#{isenable},telephone=#{telephone},mail=#{mail},addDate=#{adddate},password=#{password},remark=#{remark},station=#{station}"})
    void updateUser(User_management user);
    @Select("insert into t_user values(null,#{birthday},#{gender},#{username},#{name},#{roleId},#{loginTimes},#{isEnable},#{telephone},#{mail},#{addDate},#{password},#{remark},#{station})")
    void save(User_management user_management);
    @Delete("delete from t_user where id = #{id}")
    void deleteById(Integer id);
    @Update({"update `t_user`  set birthday=#{birthday},gender=#{gender},username=#{username},name=#{name},roleId=#{roleId},loginTimes=#{loginTimes},isEnable=#{isEnable},telephone=#{telephone},mail=#{mail},addDate=#{addDate},password=#{password},remark=#{remark},station=#{station} where id = #{id}"})
    void edit(User_management user_management);

    Page<User_management> selectByCondition(String queryString);

    @Select("<script>" +
            "select * from t_user\n" +
            "<if test=\"value != null and value.length > 0\">\n" +
            "where code like concat(concat('%',#{value}),'%') or name like concat(concat('%',#{value}),'%') or id like concat(concat('%',#{value}),'%')\n" +
            "</if>" +
            "</script>")
    List<User_management> EstimateFindAll();
}
